package ptij.vocoder.baseModel.common;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.ObjectToken;
import ptolemy.data.type.*;

import ptij.vocoder.baseModel.*;

//////////////////////////////////////////////////////////////////////////
//// Residu
/**

@author Ivan Jeukens
@version v 0.1 07/08/2003
*/
public class Residu extends TypedAtomicActor {

    public Residu(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);

        ap = new TypedIOPort(this, "ap", true, false);
        ap.setTypeEquals(BaseType.OBJECT);

        x = new TypedIOPort(this, "x", true, false);
        x.setTypeEquals(BaseType.OBJECT);

        y = new TypedIOPort(this, "y", false, true);
        y.setTypeEquals(BaseType.OBJECT);
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    // Input ports
    public TypedIOPort ap;
    public TypedIOPort x;

    // Output Ports
    public TypedIOPort y;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void initialize() throws IllegalActionException {
        super.initialize();

    }

    public void fire() throws IllegalActionException {
        ObjectToken obj = (ObjectToken) ap.get(0);
        Short [] arg1 = (Short []) obj.getValue();

        obj = (ObjectToken) x.get(0);
        Short [] arg2 = (Short []) obj.getValue();

        Short [] resp = _residu(arg1, arg2);
        obj = new ObjectToken(resp);
        y.broadcast(obj);
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    private Short [] _residu(Short [] ap, Short [] x) {
        Short [] y = new Short[Cnst.L_SUBFR];
        
        
        return y;
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

}
